<fieldset class="layui-elem-field">
  <legend>编辑个人信息</legend>
  <div class="layui-field-box">
<form class="layui-form">
  <div class="layui-form-item">
    <label class="layui-form-label">真实姓名</label>
    <div class="layui-input-inline">
      <input type="text" name="real_name" value="{$info.real_name}"  class="layui-input">
    </div>
  </div>
<div class="layui-form-item">
    <label class="layui-form-label">登入用户</label>
    <div class="layui-input-inline">
      <input type="text" name="user_name" value="{$info.user_name}"  class="layui-input" disabled="">
    </div>
  </div>
    <div class="layui-form-item">
    <label class="layui-form-label">旧密码</label>
    <div class="layui-input-inline">
      <input type="password" name="pass_word" value=""  class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">不填旧密码表示不修改密码</div>
  </div>
    <div class="layui-form-item">
    <label class="layui-form-label">新密码</label>
    <div class="layui-input-inline">
      <input type="password" name="new_pass_word" value=""  class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请填写6到12位密码</div>
  </div>
    
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="user">更新</button>
    </div>
  </div>
  <input type="text" name="style_id" value="{$info['style_id']}" style="display:none;"/>
</form>
     </div>
</fieldset>
<script>
layui.use(['upload','form', 'layedit', 'laydate'], function(){
var form = layui.form()
  ,layer = layui.layer
  ,layedit = layui.layedit
  ,laydate = layui.laydate
  ,upload  = layui.upload
  ,$ = layui.jquery;
  
	  form.on('submit(user)', function(data){
		  
	    var userInfo = data.field;
	    
		var url = "{:U('Index/edit')}";
		$.post(url,userInfo,function(data){
        	//alert(data);
        	//return;
			if(data.status == 'error'){
				  layer.msg(data.msg,{icon: 5});//失败的表情
				  return;
			  }else if(data.status == 'success'){
				  layer.msg(data.msg, {
					  icon: 6,//成功的表情
					  time: 1000 //2秒关闭（如果不配置，默认是3秒）
					}, function(){
					   location.reload();
					}); 
			  }
		})
	    return false;//阻止表单跳转
	  });
      
      //查看图片
	$(document).delegate('#back_img_str2','click',function(){
    	var src = $('#back_img_str').val();
		layer.open({
  			title: '查看图片'
  			,content: '<img width="276" height="276" src="'+src+'">'
		});   
	});
    // 重新选择图片
	$(document).delegate('.imageChange','click',function(){
		$('#back_img').show();
		$('#back_img1').hide();
	});
	layui.upload({
  		url: "{:U('Style/upload')}"
		,ext: 'jpg'
  		,success: function(res){
        	if(res.code==200){
            	$('#back_img').hide();
				$('#back_img1').show();
				$('#back_img_str').val(res.name);
            }
            if(res.code==400){
            	layer.msg(res.msg,{icon: 5});//失败的表情
				return;
            }
  		}
	});
	
    


  form.render(); 
  });
  
</script>